package org.flowable.demospringbootflowable;

import org.flowable.demospringbootflowable.service.MyService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * 参考:http://doc.miguren.cn/bpmn/#springSpringBoot
 * @author lichao9
 * @date 2021/5/21 15:15
 * @return null
 */
@SpringBootApplication
public class DemoSpringbootFlowableApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoSpringbootFlowableApplication.class, args);
    }

    @Bean
    public CommandLineRunner init(final RepositoryService repositoryService,
                                  final RuntimeService runtimeService,
                                  final TaskService taskService,
                                  final MyService myService) {

//        return new CommandLineRunner() {
//            @Override
//            public void run(String... strings) throws Exception {
//                System.out.println("Number of process definitions : "
//                        + repositoryService.createProcessDefinitionQuery().count());
//                System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
//                runtimeService.startProcessInstanceByKey("oneTaskProcess");
//                System.out.println("Number of tasks after process start: "
//                        + taskService.createTaskQuery().count());
//            }
//        };


        return new CommandLineRunner() {
            public void run(String... strings) throws Exception {
                //创建默认的用户信息
                myService.createDemoUsers();
            }
        };
    }

}
